<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
    .bootbox-close-button {
        width: 19px;
        height: 19px;
        border: none;
        cursor: pointer;
        -webkit-appearance: none;
        float: right;
        top: 4px;
        left: -5px;
        position: relative;
        background: #E9F5FF url("assets/img/nav-img/icon_close.png") no-repeat 0 0;
    }

    .attendPackageList .modal-dialog {
        width: 60% !important;
    }

    .modal-content {
        width: 100%;
    }

    input, select, .form-control {
        height: 30px;
    }

    .myDialogDetail label {
        margin-bottom: 0px !important;
    }

    .detailDialogStyle {
        line-height: 30px;
        margin-bottom: 15px;
    }
    .myDialogDetail1 .modal-body{
        padding-bottom: 0px!important;
        border-bottom-right-radius: 5px!important;
        border-bottom-left-radius: 5px!important;
    }
</style>
<div class="row">
    <!-- 映射列表 -->
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="leftTree">
        <div class="row" style="margin-bottom: 15px;margin-top:15px;font-size: 14px">
                    <span style="padding-left: 16px">
                        请选择报班所要消耗的课时包
                    </span>
        </div>
        <div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
            <div class="widget-body no-padding">
                <div class="table-scrollable" style="border: none;">
                    <!-- 数据表列信息列表 -->
                    <table class="table table-hover dataTable newtable">
                        <input type="hidden" name="memberType" class="memberType" value="${memberType}">
                        <thead>
                        <tr>
                            <th title="选择" class="checkboxColumnTh fixedColumn " fixed-align="left"></th>
                            <th title="课时包名称">课时包名称</th>
                            <th title="可出勤天数">剩余报班天数</th>
                            <th title="剩余有效时期">剩余有效时期</th>
                            <th title="课时包状态">课时包状态</th>
                            <th class="操作">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <#if memberPackagesList?size==0>
                            <tr>
                                <td align="center">无数据</td>
                            </tr>
                        </#if>
                        <#list memberPackagesList as data>
                            <tr>
                                <td class="checkboxColumnTd"><label>
                                    <input type="radio" class="chk memberPackageId" name="PackageId" value="${data.id}" packageStatus="${data.packageStatus}">
                                    <span class="text"></span> </label>
                                </td>
                                <td>${(data.name???string(data.name?html,"未设置"))!'未设置'}</td>
                                <td>${(data.surplusAttendanceDay???string(data.surplusAttendanceDay?html,"未设置"))!'未设置'}</td>
                                <td>${(data.surplusValidDate???string(data.surplusValidDate?html,"未设置"))!'未设置'}</td>
                                <td><@dictionary groupCode="packageStatus" dictionaryCode="${data.packageStatus}" ;packageStatus>${packageStatus.value }</@dictionary></td>
                                <td align="center">
                                    <#if  data.packageStatus==2 >
                                        <a onclick="changePakcageStauts(this)" targetDataId="${data.id}" title="激活">激活</a>
                                    </#if>
                                </td>

                            </tr>
                        </#list>
                        </tbody>

                    </table>
                </div>
            </div>

            <div class="col-sm-12 text-align-center margin-bottom-20 margin-top-20">
                <button style="width: 80px;" type="button" class="btn btn-blue" serializeNum="${serializeNum}" id="attendPackageListButton"
                        onclick="showDialogAttendClassNext(this)">下一步
                </button>
            </div>
        </div>
    </div>
</div>
<script>
    $(".selectpicker").select2();

    $(".memberPackageId").click(function () {
        var packageStatus = $(this).attr("packageStatus");
        if(packageStatus!=1){
            $("#attendPackageListButton").attr("disabled","disabled");
            logger.error("目前课时包不可用!");
        }
    });

    function showDialogAttendClassNext(that) {
        var memberPackageId = $(".memberPackageId").val();
        var checkedIds = getCheckedInputValues("PackageId");
        if (checkedIds) {

        } else {
            alert("请选择要分配的客户!");
            return;
        }
        ajaxRequest("tssClassesController/tssAttendClassesList.do", {
            pageSize: 10,
            type: 2,
            memberPackageId: memberPackageId
        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "过渡报班",
                className: 'myDialog tssMemberCheckAttendanceDialog'
            });
        }, function () {
            ajaxError("加载页面失败!")
        }, "post", "html")
    }
    function changePakcageStauts(that){
        var targetdataId = $(that).attr("targetDataId");
        ajaxRequest("tssMemberPackageController/updatePackageStatus.do",{
            targetDateId:targetdataId,
            packageStatus:2
        }, function (result) {
            //alert("激活成功");
            if (result.resCode == 200) {
                logger.info("激活成功!",true);
                bootbox.hideAll();
            }else {
                logger.error("激活失败"+result.resMsg);
            }
        },function(){
            ajaxError("加载员工信息失败");
        }, "post","json")

    }

</script>
